/**
 * PHOSIDE: PHosphorylation Site IDentification Engine.
 * Copyright 2009 Digital Biology Lab, University of Missouri.
 * This library is free software; you can redistribute it and/or modify it under
 * the terms of the GNU General Public License as published by the Free Software
 * Foundation; either version 3 of the License, or (at your option) any later
 * version. <p/> This library is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the License for more
 * details.
 */

package phoside.ui;

import java.util.Properties;
import java.util.Vector;

import phoside.PhosideInit;

import phoside.util.StaticFinalValues;
import phoside.util.IOUtil;

/**
 *
 * @author gjj
 */
public class TrainingOptionDialog extends javax.swing.JDialog {

    /** Creates new form TrainingOptionDialog */
    public TrainingOptionDialog(javax.swing.JDialog parent, boolean modal) {
        super(parent, modal);
        initComponents();
        setProps(PhosideInit.trainingProps);
    }

    /** This method is called from within the constructor to
     * initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is
     * always regenerated by the Form Editor.
     */
    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {
        java.awt.GridBagConstraints gridBagConstraints;

        javax.swing.JPanel classifyPanel = new javax.swing.JPanel();
        javax.swing.JPanel svmPanel = new javax.swing.JPanel();
        javax.swing.JLabel svmParamLabel = new javax.swing.JLabel();
        svmParamTextField = new javax.swing.JTextField();
        javax.swing.JPanel bottstrapPanel = new javax.swing.JPanel();
        javax.swing.JPanel noBootsPanel = new javax.swing.JPanel();
        javax.swing.JLabel noBootsLabel = new javax.swing.JLabel();
        noBootsTextField = new javax.swing.JTextField();
        javax.swing.JPanel noClassifierPanel = new javax.swing.JPanel();
        javax.swing.JLabel noBootsLabel1 = new javax.swing.JLabel();
        noClassifierTextField = new javax.swing.JTextField();
        javax.swing.JPanel modelEvalPanel = new javax.swing.JPanel();
        javax.swing.JLabel evalSizeLabel = new javax.swing.JLabel();
        evalSizeTextField = new javax.swing.JTextField();
        javax.swing.JLabel modelEvalMaxNegLabel = new javax.swing.JLabel();
        javax.swing.JPanel knnFeaturePanel = new javax.swing.JPanel();
        javax.swing.JPanel useKNNPanel = new javax.swing.JPanel();
        useKNNCheckBox = new javax.swing.JCheckBox();
        javax.swing.JPanel matrixPanel = new javax.swing.JPanel();
        javax.swing.JLabel matrixLabel = new javax.swing.JLabel();
        matrixComboBox = new javax.swing.JComboBox();
        javax.swing.JLabel knnWindowLabel = new javax.swing.JLabel();
        knnWindowTextField = new javax.swing.JTextField();
        javax.swing.JPanel selectKPanel = new javax.swing.JPanel();
        javax.swing.JLabel selectKLabel = new javax.swing.JLabel();
        selectKTextField = new javax.swing.JTextField();
        javax.swing.JLabel percentLabel = new javax.swing.JLabel();
        javax.swing.JPanel disorderFeaturePanel = new javax.swing.JPanel();
        javax.swing.JPanel useDisorderPanel = new javax.swing.JPanel();
        useDisorderCheckBox = new javax.swing.JCheckBox();
        disorderConfigPanel = new javax.swing.JPanel();
        javax.swing.JLabel disorderWindowLabel = new javax.swing.JLabel();
        disorderWindowTextField = new javax.swing.JTextField();
        javax.swing.JPanel frequencyFeaturePanel = new javax.swing.JPanel();
        javax.swing.JPanel useFrequencyPanel = new javax.swing.JPanel();
        useFrequencyCheckBox = new javax.swing.JCheckBox();
        frequencyConfigPanel = new javax.swing.JPanel();
        javax.swing.JLabel frequencyWindowLabel = new javax.swing.JLabel();
        frequencyWindowTextField = new javax.swing.JTextField();
        javax.swing.JLabel frequencyNumberLabel = new javax.swing.JLabel();
        frequencyNumberTextField = new javax.swing.JTextField();
        javax.swing.JPanel preprocessPanel = new javax.swing.JPanel();
        javax.swing.JPanel paddingPanel = new javax.swing.JPanel();
        paddingCheckBox = new javax.swing.JCheckBox();
        javax.swing.JPanel okPanel = new javax.swing.JPanel();
        okButton = new javax.swing.JButton();
        cancelButton = new javax.swing.JButton();
        javax.swing.JPanel resetPanel = new javax.swing.JPanel();
        javax.swing.JButton resetButton = new javax.swing.JButton();

        setDefaultCloseOperation(javax.swing.WindowConstants.DISPOSE_ON_CLOSE);
        setTitle("Training options");
        getContentPane().setLayout(new java.awt.GridBagLayout());

        classifyPanel.setBorder(javax.swing.BorderFactory.createTitledBorder("Classifier Training Parameters"));
        classifyPanel.setLayout(new java.awt.GridBagLayout());

        svmPanel.setBorder(javax.swing.BorderFactory.createTitledBorder("Support Vector Machine"));
        svmPanel.setLayout(new java.awt.GridBagLayout());

        svmParamLabel.setText("SVM parameters:");
        gridBagConstraints = new java.awt.GridBagConstraints();
        gridBagConstraints.gridx = 0;
        gridBagConstraints.gridy = 2;
        gridBagConstraints.anchor = java.awt.GridBagConstraints.LINE_END;
        gridBagConstraints.insets = new java.awt.Insets(0, 5, 0, 5);
        svmPanel.add(svmParamLabel, gridBagConstraints);
        gridBagConstraints = new java.awt.GridBagConstraints();
        gridBagConstraints.gridx = 1;
        gridBagConstraints.gridy = 2;
        gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL;
        gridBagConstraints.weightx = 1.0;
        gridBagConstraints.insets = new java.awt.Insets(0, 5, 0, 5);
        svmPanel.add(svmParamTextField, gridBagConstraints);

        gridBagConstraints = new java.awt.GridBagConstraints();
        gridBagConstraints.gridx = 0;
        gridBagConstraints.gridy = 0;
        gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL;
        gridBagConstraints.anchor = java.awt.GridBagConstraints.PAGE_START;
        gridBagConstraints.weightx = 1.0;
        gridBagConstraints.insets = new java.awt.Insets(0, 5, 0, 5);
        classifyPanel.add(svmPanel, gridBagConstraints);

        bottstrapPanel.setBorder(javax.swing.BorderFactory.createTitledBorder("Bootstrapping aggregation (Bagging)"));
        bottstrapPanel.setLayout(new java.awt.FlowLayout(java.awt.FlowLayout.LEFT, 5, 0));

        noBootsPanel.setLayout(new java.awt.FlowLayout(java.awt.FlowLayout.CENTER, 0, 0));

        noBootsLabel.setText("No. of boots:");
        noBootsPanel.add(noBootsLabel);

        noBootsTextField.setHorizontalAlignment(javax.swing.JTextField.RIGHT);
        noBootsTextField.setMinimumSize(new java.awt.Dimension(50, 20));
        noBootsTextField.setPreferredSize(new java.awt.Dimension(50, 20));
        noBootsPanel.add(noBootsTextField);

        bottstrapPanel.add(noBootsPanel);

        noClassifierPanel.setLayout(new java.awt.FlowLayout(java.awt.FlowLayout.CENTER, 0, 0));

        noBootsLabel1.setText("No. of classifiers:");
        noClassifierPanel.add(noBootsLabel1);

        noClassifierTextField.setHorizontalAlignment(javax.swing.JTextField.RIGHT);
        noClassifierTextField.setMinimumSize(new java.awt.Dimension(50, 20));
        noClassifierTextField.setPreferredSize(new java.awt.Dimension(50, 20));
        noClassifierPanel.add(noClassifierTextField);

        bottstrapPanel.add(noClassifierPanel);

        gridBagConstraints = new java.awt.GridBagConstraints();
        gridBagConstraints.gridx = 0;
        gridBagConstraints.gridy = 1;
        gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL;
        gridBagConstraints.anchor = java.awt.GridBagConstraints.PAGE_START;
        gridBagConstraints.weightx = 1.0;
        gridBagConstraints.insets = new java.awt.Insets(0, 5, 0, 5);
        classifyPanel.add(bottstrapPanel, gridBagConstraints);

        modelEvalPanel.setBorder(javax.swing.BorderFactory.createTitledBorder("Model evaluation"));
        modelEvalPanel.setLayout(new java.awt.FlowLayout(java.awt.FlowLayout.LEFT));

        evalSizeLabel.setText("Number of negative data for specificity estimation:");
        modelEvalPanel.add(evalSizeLabel);

        evalSizeTextField.setPreferredSize(new java.awt.Dimension(60, 19));
        modelEvalPanel.add(evalSizeTextField);

        modelEvalMaxNegLabel.setText("or 50% of all negative data, whichever is less");
        modelEvalPanel.add(modelEvalMaxNegLabel);

        gridBagConstraints = new java.awt.GridBagConstraints();
        gridBagConstraints.gridx = 0;
        gridBagConstraints.gridy = 3;
        gridBagConstraints.fill = java.awt.GridBagConstraints.BOTH;
        gridBagConstraints.insets = new java.awt.Insets(5, 5, 5, 5);
        classifyPanel.add(modelEvalPanel, gridBagConstraints);

        gridBagConstraints = new java.awt.GridBagConstraints();
        gridBagConstraints.gridx = 0;
        gridBagConstraints.gridy = 0;
        gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL;
        gridBagConstraints.weightx = 1.0;
        gridBagConstraints.insets = new java.awt.Insets(5, 5, 5, 5);
        getContentPane().add(classifyPanel, gridBagConstraints);

        knnFeaturePanel.setBorder(javax.swing.BorderFactory.createTitledBorder("KNN Feature Parameters"));
        knnFeaturePanel.setLayout(new java.awt.GridBagLayout());

        useKNNPanel.setLayout(new java.awt.FlowLayout(java.awt.FlowLayout.LEFT, 5, 3));

        useKNNCheckBox.setText("Using K-Nearest Neighbors (KNN) features");
        useKNNPanel.add(useKNNCheckBox);

        gridBagConstraints = new java.awt.GridBagConstraints();
        gridBagConstraints.gridx = 0;
        gridBagConstraints.gridy = 0;
        gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL;
        gridBagConstraints.anchor = java.awt.GridBagConstraints.LINE_START;
        gridBagConstraints.weightx = 1.0;
        knnFeaturePanel.add(useKNNPanel, gridBagConstraints);

        matrixPanel.setLayout(new java.awt.GridBagLayout());

        matrixLabel.setText("Substitution matrix:");
        gridBagConstraints = new java.awt.GridBagConstraints();
        gridBagConstraints.gridx = 0;
        gridBagConstraints.gridy = 0;
        gridBagConstraints.insets = new java.awt.Insets(3, 5, 3, 3);
        matrixPanel.add(matrixLabel, gridBagConstraints);

        String matrixDir = PhosideInit.matrixDir.getAbsolutePath();
        Vector<String> matrices = new Vector<String>(phoside.util.IOUtil.listFilesInFolder(matrixDir));
        matrices.remove("error.log");
        matrixComboBox.setModel(new javax.swing.DefaultComboBoxModel(matrices));
        matrixComboBox.setMinimumSize(new java.awt.Dimension(100, 18));
        matrixComboBox.setPreferredSize(new java.awt.Dimension(100, 20));
        gridBagConstraints = new java.awt.GridBagConstraints();
        gridBagConstraints.gridx = 1;
        gridBagConstraints.gridy = 0;
        gridBagConstraints.insets = new java.awt.Insets(3, 3, 3, 15);
        matrixPanel.add(matrixComboBox, gridBagConstraints);

        knnWindowLabel.setText("Sequence window size:");
        gridBagConstraints = new java.awt.GridBagConstraints();
        gridBagConstraints.gridx = 2;
        gridBagConstraints.gridy = 0;
        gridBagConstraints.insets = new java.awt.Insets(3, 15, 3, 3);
        matrixPanel.add(knnWindowLabel, gridBagConstraints);

        knnWindowTextField.setHorizontalAlignment(javax.swing.JTextField.RIGHT);
        knnWindowTextField.setMinimumSize(new java.awt.Dimension(30, 20));
        knnWindowTextField.setPreferredSize(new java.awt.Dimension(30, 20));
        gridBagConstraints = new java.awt.GridBagConstraints();
        gridBagConstraints.gridx = 3;
        gridBagConstraints.gridy = 0;
        gridBagConstraints.insets = new java.awt.Insets(3, 3, 3, 3);
        matrixPanel.add(knnWindowTextField, gridBagConstraints);

        gridBagConstraints = new java.awt.GridBagConstraints();
        gridBagConstraints.gridx = 0;
        gridBagConstraints.gridy = 1;
        gridBagConstraints.anchor = java.awt.GridBagConstraints.LINE_START;
        knnFeaturePanel.add(matrixPanel, gridBagConstraints);

        selectKPanel.setLayout(new java.awt.FlowLayout(java.awt.FlowLayout.CENTER, 5, 3));

        selectKLabel.setText("Size of neighbors (K) in percentage of bootstrapped sample size:");
        selectKPanel.add(selectKLabel);

        selectKTextField.setHorizontalAlignment(javax.swing.JTextField.RIGHT);
        selectKTextField.setMinimumSize(new java.awt.Dimension(100, 20));
        selectKTextField.setPreferredSize(new java.awt.Dimension(100, 20));
        selectKPanel.add(selectKTextField);

        percentLabel.setText("%");
        selectKPanel.add(percentLabel);

        gridBagConstraints = new java.awt.GridBagConstraints();
        gridBagConstraints.gridx = 0;
        gridBagConstraints.gridy = 3;
        gridBagConstraints.anchor = java.awt.GridBagConstraints.LINE_START;
        knnFeaturePanel.add(selectKPanel, gridBagConstraints);

        gridBagConstraints = new java.awt.GridBagConstraints();
        gridBagConstraints.gridx = 0;
        gridBagConstraints.gridy = 1;
        gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL;
        gridBagConstraints.insets = new java.awt.Insets(5, 5, 5, 5);
        getContentPane().add(knnFeaturePanel, gridBagConstraints);

        disorderFeaturePanel.setBorder(javax.swing.BorderFactory.createTitledBorder("Disorder Feature Parameter"));
        disorderFeaturePanel.setLayout(new java.awt.GridBagLayout());

        useDisorderPanel.setLayout(new java.awt.FlowLayout(java.awt.FlowLayout.LEFT, 5, 0));

        useDisorderCheckBox.setText("Using protein disorder features");
        useDisorderPanel.add(useDisorderCheckBox);

        gridBagConstraints = new java.awt.GridBagConstraints();
        gridBagConstraints.gridx = 0;
        gridBagConstraints.gridy = 0;
        gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL;
        gridBagConstraints.anchor = java.awt.GridBagConstraints.LINE_START;
        gridBagConstraints.weightx = 1.0;
        disorderFeaturePanel.add(useDisorderPanel, gridBagConstraints);

        disorderConfigPanel.setLayout(new java.awt.FlowLayout(java.awt.FlowLayout.LEFT, 10, 0));

        disorderWindowLabel.setText("Sequence window sizes:");
        disorderConfigPanel.add(disorderWindowLabel);

        disorderWindowTextField.setHorizontalAlignment(javax.swing.JTextField.RIGHT);
        disorderWindowTextField.setMinimumSize(new java.awt.Dimension(100, 20));
        disorderWindowTextField.setPreferredSize(new java.awt.Dimension(100, 20));
        disorderConfigPanel.add(disorderWindowTextField);

        gridBagConstraints = new java.awt.GridBagConstraints();
        gridBagConstraints.gridx = 0;
        gridBagConstraints.gridy = 2;
        gridBagConstraints.fill = java.awt.GridBagConstraints.BOTH;
        gridBagConstraints.anchor = java.awt.GridBagConstraints.LINE_START;
        gridBagConstraints.weightx = 1.0;
        gridBagConstraints.weighty = 1.0;
        disorderFeaturePanel.add(disorderConfigPanel, gridBagConstraints);

        gridBagConstraints = new java.awt.GridBagConstraints();
        gridBagConstraints.gridx = 0;
        gridBagConstraints.gridy = 2;
        gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL;
        gridBagConstraints.weightx = 1.0;
        gridBagConstraints.insets = new java.awt.Insets(5, 5, 5, 5);
        getContentPane().add(disorderFeaturePanel, gridBagConstraints);

        frequencyFeaturePanel.setBorder(javax.swing.BorderFactory.createTitledBorder("Frequency Feature Parameter"));
        frequencyFeaturePanel.setLayout(new java.awt.GridBagLayout());

        useFrequencyPanel.setLayout(new java.awt.FlowLayout(java.awt.FlowLayout.LEFT, 5, 0));

        useFrequencyCheckBox.setText("Using amino acid frequency features");
        useFrequencyPanel.add(useFrequencyCheckBox);

        gridBagConstraints = new java.awt.GridBagConstraints();
        gridBagConstraints.gridx = 0;
        gridBagConstraints.gridy = 0;
        gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL;
        gridBagConstraints.anchor = java.awt.GridBagConstraints.LINE_START;
        gridBagConstraints.weightx = 1.0;
        frequencyFeaturePanel.add(useFrequencyPanel, gridBagConstraints);

        frequencyConfigPanel.setLayout(new java.awt.GridBagLayout());

        frequencyWindowLabel.setText("Sequence window size:");
        gridBagConstraints = new java.awt.GridBagConstraints();
        gridBagConstraints.gridx = 0;
        gridBagConstraints.gridy = 0;
        gridBagConstraints.anchor = java.awt.GridBagConstraints.LINE_START;
        gridBagConstraints.insets = new java.awt.Insets(3, 5, 3, 3);
        frequencyConfigPanel.add(frequencyWindowLabel, gridBagConstraints);

        frequencyWindowTextField.setHorizontalAlignment(javax.swing.JTextField.RIGHT);
        frequencyWindowTextField.setMinimumSize(new java.awt.Dimension(30, 20));
        frequencyWindowTextField.setPreferredSize(new java.awt.Dimension(30, 20));
        gridBagConstraints = new java.awt.GridBagConstraints();
        gridBagConstraints.gridx = 1;
        gridBagConstraints.gridy = 0;
        gridBagConstraints.anchor = java.awt.GridBagConstraints.LINE_START;
        gridBagConstraints.insets = new java.awt.Insets(3, 3, 3, 15);
        frequencyConfigPanel.add(frequencyWindowTextField, gridBagConstraints);

        frequencyNumberLabel.setText("Number of frequency features (1-20):");
        gridBagConstraints = new java.awt.GridBagConstraints();
        gridBagConstraints.gridx = 2;
        gridBagConstraints.gridy = 0;
        gridBagConstraints.anchor = java.awt.GridBagConstraints.LINE_START;
        gridBagConstraints.insets = new java.awt.Insets(3, 15, 3, 3);
        frequencyConfigPanel.add(frequencyNumberLabel, gridBagConstraints);

        frequencyNumberTextField.setHorizontalAlignment(javax.swing.JTextField.RIGHT);
        frequencyNumberTextField.setMinimumSize(new java.awt.Dimension(30, 20));
        frequencyNumberTextField.setPreferredSize(new java.awt.Dimension(30, 20));
        gridBagConstraints = new java.awt.GridBagConstraints();
        gridBagConstraints.gridx = 3;
        gridBagConstraints.gridy = 0;
        gridBagConstraints.insets = new java.awt.Insets(3, 3, 3, 3);
        frequencyConfigPanel.add(frequencyNumberTextField, gridBagConstraints);

        gridBagConstraints = new java.awt.GridBagConstraints();
        gridBagConstraints.gridx = 0;
        gridBagConstraints.gridy = 1;
        gridBagConstraints.anchor = java.awt.GridBagConstraints.LINE_START;
        frequencyFeaturePanel.add(frequencyConfigPanel, gridBagConstraints);

        gridBagConstraints = new java.awt.GridBagConstraints();
        gridBagConstraints.gridx = 0;
        gridBagConstraints.gridy = 3;
        gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL;
        gridBagConstraints.insets = new java.awt.Insets(5, 5, 5, 5);
        getContentPane().add(frequencyFeaturePanel, gridBagConstraints);

        preprocessPanel.setBorder(javax.swing.BorderFactory.createTitledBorder("Preprocessing"));
        preprocessPanel.setLayout(new java.awt.GridBagLayout());

        paddingPanel.setLayout(new java.awt.FlowLayout(java.awt.FlowLayout.LEFT, 5, 0));

        paddingCheckBox.setText("Pad the terminals with * for training");
        paddingPanel.add(paddingCheckBox);

        gridBagConstraints = new java.awt.GridBagConstraints();
        gridBagConstraints.gridx = 0;
        gridBagConstraints.gridy = 0;
        gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL;
        gridBagConstraints.anchor = java.awt.GridBagConstraints.LINE_START;
        gridBagConstraints.weightx = 1.0;
        preprocessPanel.add(paddingPanel, gridBagConstraints);

        gridBagConstraints = new java.awt.GridBagConstraints();
        gridBagConstraints.gridx = 0;
        gridBagConstraints.gridy = 4;
        gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL;
        gridBagConstraints.insets = new java.awt.Insets(5, 5, 5, 5);
        getContentPane().add(preprocessPanel, gridBagConstraints);

        okPanel.setLayout(new javax.swing.BoxLayout(okPanel, javax.swing.BoxLayout.LINE_AXIS));

        okButton.setText("   OK   ");
        okButton.setToolTipText("");
        okButton.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                okButtonActionPerformed(evt);
            }
        });
        okPanel.add(okButton);

        cancelButton.setText("Cancel");
        cancelButton.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                cancelButtonActionPerformed(evt);
            }
        });
        okPanel.add(cancelButton);

        gridBagConstraints = new java.awt.GridBagConstraints();
        gridBagConstraints.gridx = 0;
        gridBagConstraints.gridy = 5;
        gridBagConstraints.anchor = java.awt.GridBagConstraints.LINE_END;
        gridBagConstraints.weightx = 1.0;
        gridBagConstraints.insets = new java.awt.Insets(5, 5, 5, 5);
        getContentPane().add(okPanel, gridBagConstraints);

        resetPanel.setLayout(new javax.swing.BoxLayout(resetPanel, javax.swing.BoxLayout.LINE_AXIS));

        resetButton.setText("Reset all to default");
        resetButton.setToolTipText("");
        resetButton.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                resetButtonActionPerformed(evt);
            }
        });
        resetPanel.add(resetButton);

        gridBagConstraints = new java.awt.GridBagConstraints();
        gridBagConstraints.gridx = 0;
        gridBagConstraints.gridy = 5;
        gridBagConstraints.anchor = java.awt.GridBagConstraints.LINE_START;
        gridBagConstraints.insets = new java.awt.Insets(5, 5, 5, 5);
        getContentPane().add(resetPanel, gridBagConstraints);

        pack();
    }// </editor-fold>//GEN-END:initComponents

    private void cancelButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_cancelButtonActionPerformed
        setVisible(false);
}//GEN-LAST:event_cancelButtonActionPerformed

    private void okButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_okButtonActionPerformed
        // TODO: verify input
        saveParam();
        cancelled = false;
        setVisible(false);
}//GEN-LAST:event_okButtonActionPerformed

    private void resetButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_resetButtonActionPerformed
        Properties defProps = PhosideInit.defaultTrainingProps();
        setProps(defProps);
}//GEN-LAST:event_resetButtonActionPerformed

    public boolean isCancelled() {
        return this.cancelled;
    }

    private void setProps(Properties props) {
        svmParamTextField.setText(props.getProperty(StaticFinalValues.SVMPARAMETERS));

        noBootsTextField.setText(props.getProperty(StaticFinalValues.NOOFBOOTS));
        noClassifierTextField.setText(props.getProperty(StaticFinalValues.NOOFCLASSIFIERS));

        evalSizeTextField.setText(props.getProperty(StaticFinalValues.NEGATIVECONTROLSIZE));

        useKNNCheckBox.setSelected(props.getProperty(StaticFinalValues.USEKNNFEATURES).equalsIgnoreCase("true"));
        matrixComboBox.setSelectedItem(props.getProperty(StaticFinalValues.SUBSTITUTIONMATRIX));
        knnWindowTextField.setText(props.getProperty(StaticFinalValues.KNNWINDOWSIZE));
        selectKTextField.setText(props.getProperty(StaticFinalValues.KNNNEIGHBORSIZES));

        useDisorderCheckBox.setSelected(props.getProperty(StaticFinalValues.USEDISORDERFEATURES).equalsIgnoreCase("true"));
        disorderWindowTextField.setText(props.getProperty(StaticFinalValues.DISORDERWINDOWSIZES));

        useFrequencyCheckBox.setSelected(props.getProperty(StaticFinalValues.USEFREQUENCYFEATURES).equalsIgnoreCase("true"));
        frequencyWindowTextField.setText(props.getProperty(StaticFinalValues.FREQUENCYWINDOWSIZE));
        frequencyNumberTextField.setText(props.getProperty(StaticFinalValues.FREQUENCYFEATURENUMBER));

        paddingCheckBox.setSelected(props.getProperty(StaticFinalValues.PADDINGTERMINALS).equalsIgnoreCase("true"));
    }

    private void saveParam() {

        PhosideInit.trainingProps.setProperty(StaticFinalValues.SVMPARAMETERS,svmParamTextField.getText());

        PhosideInit.trainingProps.setProperty(StaticFinalValues.NOOFBOOTS,noBootsTextField.getText());
        PhosideInit.trainingProps.setProperty(StaticFinalValues.NOOFCLASSIFIERS,noClassifierTextField.getText());

        PhosideInit.trainingProps.setProperty(StaticFinalValues.NEGATIVECONTROLSIZE, evalSizeTextField.getText());

        PhosideInit.trainingProps.setProperty(StaticFinalValues.USEKNNFEATURES,useKNNCheckBox.isSelected()?"true":"false");
        PhosideInit.trainingProps.setProperty(StaticFinalValues.SUBSTITUTIONMATRIX,(String)matrixComboBox.getSelectedItem());
        PhosideInit.trainingProps.setProperty(StaticFinalValues.KNNWINDOWSIZE,knnWindowTextField.getText());
        PhosideInit.trainingProps.setProperty(StaticFinalValues.KNNNEIGHBORSIZES,selectKTextField.getText());

        PhosideInit.trainingProps.setProperty(StaticFinalValues.USEDISORDERFEATURES,useDisorderCheckBox.isSelected()?"true":"false");
        PhosideInit.trainingProps.setProperty(StaticFinalValues.DISORDERWINDOWSIZES,disorderWindowTextField.getText());

        PhosideInit.trainingProps.setProperty(StaticFinalValues.USEFREQUENCYFEATURES,useFrequencyCheckBox.isSelected()?"true":"false");
        PhosideInit.trainingProps.setProperty(StaticFinalValues.FREQUENCYWINDOWSIZE,frequencyWindowTextField.getText());
        PhosideInit.trainingProps.setProperty(StaticFinalValues.FREQUENCYFEATURENUMBER,frequencyNumberTextField.getText());

        PhosideInit.trainingProps.setProperty(StaticFinalValues.PADDINGTERMINALS,paddingCheckBox.isSelected()?"true":"false");
        
        PhosideInit.saveTrainingProps();
    }

    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JButton cancelButton;
    private javax.swing.JPanel disorderConfigPanel;
    private javax.swing.JTextField disorderWindowTextField;
    private javax.swing.JTextField evalSizeTextField;
    private javax.swing.JPanel frequencyConfigPanel;
    private javax.swing.JTextField frequencyNumberTextField;
    private javax.swing.JTextField frequencyWindowTextField;
    private javax.swing.JTextField knnWindowTextField;
    private javax.swing.JComboBox matrixComboBox;
    private javax.swing.JTextField noBootsTextField;
    private javax.swing.JTextField noClassifierTextField;
    private javax.swing.JButton okButton;
    private javax.swing.JCheckBox paddingCheckBox;
    private javax.swing.JTextField selectKTextField;
    private javax.swing.JTextField svmParamTextField;
    private javax.swing.JCheckBox useDisorderCheckBox;
    private javax.swing.JCheckBox useFrequencyCheckBox;
    private javax.swing.JCheckBox useKNNCheckBox;
    // End of variables declaration//GEN-END:variables
    private boolean cancelled = true;
}
